
// export default function({$axios}) {
//   this.$axios.setHeader('Content-Type', 'application/x-www-form-urlencoded', [])
// }

export default function ({ $axios, redirect }) {


  $axios.onRequest(config => {
    // $axios.setToken('324875893475iegfidf897g3hhfd9uyh')
    // config.headers['authorization'] = '12342453245234'
    // config.headers['Accept'] = 'application/x-www-form-urlencoded'
    // config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    // console.log('Making request to ' + config.url)
    // console.log(config)
  })

  $axios.onResponse(res => {
    if (res.data.code == 2022) {
      redirect('/login')
    }
  })

  $axios.onError(error => {
    const code = parseInt(error.response && error.response.status)
    if (code === 400) {
      redirect('/login')
    }
  })
}
